<%extends"admin/base.html"%><%block content%>
<div class="layui-card">
  <div class="layui-form layui-card-header layuiadmin-card-header-auto">
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-inline">
          <input type="text" name="title" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-inline">
        <button class="layui-btn" lay-submit lay-filter="LAY-app-contlist-search">
          <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
        </button>
      </div>
    </div>
  </div>

  <div class="layui-card-body">
    <table id="LAY-app-content-list" lay-filter="LAY-app-content-list"></table>
    <script type="text/html" id="table-content-list">
      <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="blank"><i class="layui-icon layui-icon-edit"></i>查看</a>
        <a class="layui-btn layui-btn-warning layui-btn-xs" lay-event="load"><i class="layui-icon layui-icon-star"></i>导入</a>
    </script>
  </div>
</div>
<%endblock%>
<%block script%>
    //监听搜索
    form.on('submit(LAY-app-contlist-search)', function(data){
      var field = data.field;

      //执行重载
      table.reload('LAY-app-content-list', {
        where: field,
        method:'post'
      });
    });
    table.render({
        elem: "#LAY-app-content-list",
        url: "<< url_for('admin.BlogCSDNList') >>",
        text: {
            none: '暂无相关数据', //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            error:'对不起，加载出现异常！'
        },
        method:'post',
        cols: [[{field: "Id", width: 100, title: "文章ID", sort: !0}, {
            field: "tag",
            title: "文章分类",
            minWidth: 50
        }, {field: "title", title: "文章标题"},{
            field: "createTime",
            title: "上传时间",
            sort: !0
        },{
            title: "操作",
            minWidth: 150,
            align: "center",
            fixed: "right",
            toolbar: "#table-content-list"
        }]],
        page: !0,
        limit: 15,
        limits: [10, 15, 20, 25, 30]
    })
    table.on("tool(LAY-app-content-list)", function (t){
        var e = t.data;
        if("blank" === t.event)
        {
            var index=layer.open({type:2,title:'原始页面',content:e.href,closeBtn:1,maxmin:!0});
            layer.full(index);
        }
        else if("load" === t.event){
            $.ajax({
                url: "<< url_for('admin.BlogImport') >>",
                type:'post',
                data:{Id:e.Id},
                dataType:'json',
                success: function (returnData) {
                    if (returnData.status == 1) {
                        layer.msg('已导入，'+e.title);
                    }
                    else {
                        layer.msg(e.title+'，'+returnData.msg);
                    }
                }
            });
        }
    })
    $('.layui-nav-child dd').removeClass('layui-this');
    $('#view_admin_csdn_list').addClass('layui-this');
    $('.layui-nav-tree li').removeClass('layui-nav-itemed');
    $('#admin_blog_nav').addClass('layui-nav-itemed');
<%endblock%>